package com.dayuanit.controller;

import com.dayuanit.controller.request.AddWarehouseRecordParam;
import com.dayuanit.response.ExResponse;
import com.dayuanit.service.WarehouseRecordService;
import com.dayuanit.util.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping(value = "warehouseRecord")
public class WarehouseRecordController {


    @Autowired
    private WarehouseRecordService warehouseRecordService;


    @GetMapping(value = "queryWarehouseRecordList")
    public ExResponse queryWarehouseRecordList(@RequestParam(value = "page") Integer page,
                                               @RequestParam(value = "limit") Integer pageSize) {
        PageInfo pageInfo = warehouseRecordService.queryWarehouseRecordList(page, pageSize);
        return ExResponse.buildSuccessList(pageInfo.getData(), pageInfo.getTotalCount());
    }


    @PostMapping(value = "addWarehouseRecord")
    public ExResponse addWarehouseRecord(@RequestBody AddWarehouseRecordParam param) {
        warehouseRecordService.addWarehouseRecord(param);
        return ExResponse.buildSuccessWithoutInfo();
    }


    @PostMapping(value = "deleteWarehouseRecord")
    public ExResponse batchDeleteWarehouseRecord(@RequestBody List<Long> idList) {
        warehouseRecordService.batchDeleteWarehouseRecord(idList);
        return ExResponse.buildSuccessWithoutInfo();
    }
}
